package com.lzy.managersystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzy.managersystem.mapper.CommentMapper;
import com.lzy.managersystem.pojo.Comment;
import com.lzy.managersystem.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lzy
 * @description 针对表【t_comment】的数据库操作Service实现
 * @createDate 2022-07-25 15:25:11
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment>
        implements CommentService {


    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<Comment> getComment(Integer id) {
        return commentMapper.selectComment(id);
    }

    @Override
    public List<Comment> getAllUser() {
        return commentMapper.selectAll();
    }

    @Override
    public int insterUser(Comment comment) {
        return commentMapper.insertSelective(comment);
    }

    @Override
    public int deleteUser(Integer id) {
        int flag;
        Comment comment = commentMapper.selectById(id);
        if (comment.getOriginId() == null) {
            flag = commentMapper.deleteByOriginId(id);
        } else {
            flag = commentMapper.delByPid(id);
        }
        flag = commentMapper.delById(id);
        return flag;
    }

    @Override
    public int updateUser(Comment comment) {
        return commentMapper.updateSelective(comment);
    }
}




